import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '单位代码',
    align:"center",
    width: 180,
    dataIndex: 'id'
  },
  {
    title: '名称',
    align:"center",
    width: 260,
    dataIndex: 'name'
  },
   {
    title: '类型',
    align:"center",
     width: 80,
     dataIndex: 'type',
     customRender: ({ text }) => {
       return render.renderDict(text, 'gxdw_type');
     }
   },
  {
    title: '上级单位代码',
    align:"center",
    width: 180,
    dataIndex: 'pid'
  },
   {
    title: '全称',
    align:"center",
    dataIndex: 'namepath'
   }
];

//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '单位代码',
    field: 'id',
    component: 'JInput',
    colProps: { span: 6 },
  },
  {
    label: '名称',
    field: 'name',
    component: 'JInput',
    colProps: { span: 6 },
  },
  {
    label: '类型',
    field: 'type',
    component: 'JSelectMultiple',
    componentProps: {
      dictCode: 'gxdw_type',
      placeholder: '请选择等级',
    },
    colProps: { span: 4 },
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: 'iid',
    field: 'iid',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入iid!'},
          ];
     },
  },
  {
    label: '上级单位代码',
    field: 'pid',
    component: 'Input',
  },
  {
    label: '等级 省厅1 市局2 分县局3 派出所4 警务区5',
    field: 'type',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入等级 省厅1 市局2 分县局3 派出所4 警务区5!'},
          ];
     },
  },
  {
    label: '名称',
    field: 'name',
    component: 'Input',
  },
  {
    label: '全称',
    field: 'fullname',
    component: 'Input',
  },
  {
    label: '是否有叶子节点: 1是0否',
    field: 'izLeaf',
    component: 'Input',
  },
  {
    label: '名称路径，-分隔',
    field: 'namepath',
    component: 'Input',
  },
  {
    label: '区划代码路径，-分隔',
    field: 'idpath',
    component: 'Input',
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  iid: {title: 'iid',order: 0,view: 'number', type: 'number',},
  pid: {title: '上级单位代码',order: 1,view: 'text', type: 'string',},
  type: {title: '等级 省厅1 市局2 分县局3 派出所4 警务区5',order: 2,view: 'text', type: 'string',},
  name: {title: '名称',order: 3,view: 'text', type: 'string',},
  fullname: {title: '全称',order: 4,view: 'text', type: 'string',},
  izLeaf: {title: '是否有叶子节点: 1是0否',order: 5,view: 'text', type: 'string',},
  namepath: {title: '名称路径，-分隔',order: 6,view: 'text', type: 'string',},
  idpath: {title: '区划代码路径，-分隔',order: 7,view: 'text', type: 'string',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
